﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="renderer" content="blink" />
    <title>基础数据</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .dSearch .btn {
            margin-top: 10px;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .modal-body .input-group-addon {
            width: 105px;
        }

        .modal-body .input-group {
            margin-bottom: 10px;
            width: 100%;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }
        #treeview1 ul li a {
            color: #808080;
            display: block;
        }

        .list-group-item {
            padding: 8px 15px;
        }
    </style>
</head>
<body class="fixed-sidebar full-height-layout gray-bg">
    <form id="form1" runat="server">
        <div id="dMain">
            <div class="wrapper wrapper-content animated fadeInRight">
                <table style="width: 100%;">
                    <tr>
                        <td style="vertical-align: top; width: 180px;">
                            <div class="ibox float-e-margins" style="width: 180px; margin-bottom: 0px;">
                                <div class="ibox-title">
                                    <h5>基础数据导航</h5>
                                    <a  onclick="showPage('添加分类信息','@Url.Action("BaseDataMainEdit","BaseData")?DMID='+$('a.jstree-clicked').attr('DMID'),800,650,false,function(){$('a.jstree-clicked').first().click()})"><i class="fa fa-plus"></i>新增</a>
                                </div>
                                <div class="ibox-content" style="padding: 10px;">
                                    <div id="treeview1" class="test treeview">
                                        <ul class="list-group" style="margin-bottom: 0px;">
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </td>
                        <td style="vertical-align: top; padding-left: 10px;">
                            <div class="ibox" style="margin-bottom: 0px;">
                                <div class="ibox-title">
                                    <h5 id="ibox-title-h5"></h5>
                                </div>
                                <div class="ibox-content">
                                    <div id="toolbar" class="dSearch">
                                        <button class="btn btn-primary btn-sm" type="button" onclick="showPage('添加信息','@Url.Action("BaseDataEdit","BaseData")?DataType=<%=DataType %>',450,460,true)">添加信息</button>
                                    </div>
                                    <table id="tabData" class="table table-bordered" style="width: 100%;">
                                        <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>名称</th>
                                                <th>代码</th>
                                                <th>其他码</th>
                                                <th>检索码</th>
                                                <th>备注</th>
                                                <th>停用</th>
                                                <th>索引</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <input id="hfLogInfo" type="hidden" value="删除了一条数据" />
        <input id="hfModular" type="hidden" value="基础数据" />
        <input id="hfPageUrl" type="hidden" value="@ViewBag.reurl" />

        <div id="dJson" style="display: none;"><%=GetJsonData() %></div>

        <script src="/js/jquery.min.js?v=2.1.4"></script>
        <script src="/js/bootstrap.min.js?v=3.3.6"></script>
        <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
        <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
        <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
        <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
        <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
        <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>

        <script src="/js/My97DatePicker/WdatePicker.js"></script>
        <script src="/js/plugins/layer/layer.min.js"></script>
        <script src="/js/verification.js"></script>
        <script src="/js/zuiCode.js"></script>

        <script type="text/javascript">
            (function ($) {
                $.basedata = {
                    init: function () {
                        //设置高度
                        var ContentHeight = document.documentElement.clientHeight - 90;
                        $("#treeview1").parent().height(ContentHeight);

                        //decodeURI解析
                        //encodeURI编码
                        var url = decodeURI(location.href).toUpperCase();
                        var par = QueryString("DataType");
                        $("li.node-treeview1").each(function (i) {
                            var href = decodeURI($(this).find("a").attr("href")).toUpperCase();
                            if (url.indexOf(href) != -1 || (url.indexOf(("BaseData.aspx").toUpperCase()) != -1 && par == undefined && i == 0)) {
                                $(this).addClass("node-selected").css({ "background-color": "#18a689" });
                                $(this).find("a").css({ "color": "#ffffff" });
                            }
                        });
                        $.ajax({
                        type: "get",
                        url: "@Url.Action("GetMainData", "BaseData")",
                        dataType: "json",
                        async: true,
                       // data: { DMID: _DMID },
                        success: function (msg) {
                            if (msg!=null) {
                                $.each(msg, function (key, value) {  //遍历键值对
                                    for (var item in value) {                                       
                                        if (item == "BDName") {
                                            $('#treeview1 ul').append("<li class=\"list-group-item node-treeview1\"><a onclick=\"GetTabData('" + value["BDName"] + "')\"><i class=\"fa fa-clock-o\"></i>&nbsp;" + value["BDName"] + "</a></li>")
                                        }}
                                })
                                $("#treeview1 ul li a").first().click();
                            }
                        }
                        });
                    }
                };
                $(function () {
                    $.basedata.init();
                });
            })(jQuery);


            function GetTabData(_type) {
                $("#ibox-title-h5").text(_type);
                $.ajax({
                    type: "post",
                    url: "@Url.Action("GetSubData", "BaseData")",
                    dataType: "json",
                    async: true,
                    data: { Type: _type },
                    success: function (msg) {
                        if (msg != null) {
                            BuildTable(msg);
                        }
                    }
                });
            }
            function BuildTable(DataJson) {
                        var tabHeight = document.documentElement.clientHeight - 100;
                        //var DataStr = $("#dJson").text();//数据源
                        //var DataJson = DataStr != "" ? JSON.parse(DataStr) : "";//格式化为json
                        $('#tabData').bootstrapTable({
                            height: tabHeight,
                            //method: "get",
                            //url: "@Url.Action("GetSubData", "BaseData")?Type=" + $("#treeview1 ul li node-selected").text(),
                            data: DataJson,
                            dataType: "json",
                            columns: [
                                { align: 'center', width: "50px", checkbox: true },
                                { field: 'BDName', align: 'center', width: "100px", sortable: true },
                                { field: 'PinYinNo', align: 'center', width: "120px" },
                                { field: 'OtherNo', align: 'center', width: "120px" },
                                { field: 'Bak1', align: 'center', width: "120px" },
                                { field: 'Remark', align: 'left' },
                                {
                                    align: 'center', width: "50px", formatter: function (value, row, index) {
                                        return ["<i class=\"ihand fa fa-" + (row.State == "1" ? "check-square-o" : "square-o") + " text-success\" onclick=\"ChangeState('TBaseData','" + row.ID + "','State','" + row.State + "')\"></i>"]
                                    }
                                },
                                { field: 'Flag1', align: 'center', width: "50px", sortable: true },
                                { align: 'center', width: "100px", formatter: operateFormatter }
                            ],
                            toolbar: '#toolbar',//工具按钮用哪个容器
                            buttonsClass: "sm btn-white",//按钮class
                            pageSize: 100,//分页条数
                            clickToSelect: true,//设置true将在点击行时，自动选择单选或复选框
                            singleSelect: true,//为true则禁止多选
                            cache: false,//是否缓存
                            cookie: false,//是否启用cookie
                            cookieIdTable: "BaseData",//cookie键值
                            pagination: true,//是否分页
                            showColumns: true,//是否显示所有的列
                            showRefresh: true,//是否显示刷新按钮
                            search: true,//是否启用搜索
                            showPaginationSwitch: true,//是否显示分页切换按钮
                            showExport: true,//是否启用导出
                            striped: false//是否显示行间隔色
                        });
                    }

            function operateFormatter(value, row, index) {
                return [
                    "<a title=\"修改\" class=\"text-success\" href=\"javascript:;\" onclick=\"showPage('修改基础信息','/BaseDataEdit.aspx?ID=" + row.ID + "',450,460,true)\">编辑</a>&emsp;" +
                    "<a title=\"删除\" class=\"text-danger\" href=\"javascript:;\" onclick=\"_Confirm('确定要删除这条数据？',function(){ DelDataReal('TBaseData','" + row.ID + "') })\">删除</a>"
                ];
            }
        </script>

        <uc1:dLeft runat="server" ID="dLeft" />
    </form>
</body>
</html>